import { nailerService } from './../../../../../providers/nailerService';
import { StorageService } from './../../../../../providers/StorageService';
import { BasePage } from './../../../../basePage';
import { Component, Injector } from '@angular/core';
import { IonicPage } from 'ionic-angular';
import { Events } from 'ionic-angular';
import { PIC_URL } from "./../../../../../providers/Config";


/**
 * Generated class for the MyMasterPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-my-master',
  templateUrl: 'my-master.html',
})
export class MyMasterPage extends BasePage {

  picrooturl = "";//图片服务地址
  user_info: any;
  teacherinfo = [];

  constructor(injector: Injector, public nailerservice: nailerService, public events: Events, public storage: StorageService) {
    super(injector);
    this.picrooturl = PIC_URL
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad MyShopPage');
    this.user_info = this.storage.read('userinfo');
    this.showShopManageAPI();    
    console.log('我已经执行');
  }


  /**添加美甲师 */
  goToPlus() {
    this.navCtrl.push("TeacherSearchPage");

  }

   dismissCLI() {
    this.navCtrl.pop()
  }

  /**删除美甲师 */
  removeItem(item) {

  }

  /*跳转到搜索美甲师id页面 */
  goTo() {
    this.navCtrl.push("TeacherSearchPage");
  }

  /**获取美甲师的列表页面 */
  async showShopManageAPI() {
    let param = { 'user_id': this.user_info.user_id };
    let result = await this.nailerservice.showShopManageAPI(param);
    console.log(result);
    if (result.code == 1) {
      this.teacherinfo = result.data;
    } else {
      let toast = this.toastCtrl.create({
        message: result.msg,
        duration: 3000,
        position: 'top',
      })
      toast.present();
    }
  }


  items:any;

  doInfinite(infiniteScroll) {
    console.log('Begin async operation');

    setTimeout(() => {
      for (let i = 0; i < 30; i++) {
        this.items.push( this.items.length );
      }

      console.log('Async operation has ended');
      infiniteScroll.complete();
    }, 500);
  }

}
